package com.invest.config;

import com.invest.utils.io.FileIOUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.io.File;

/**
 * <p>注释</p>
 *
 * @author yuyizhao
 * @version v0.1 2016/3/15 Exp
 */
@ConfigurationProperties(locations = "classpath:application.yml",
        ignoreUnknownFields = false, prefix = "app")
@Configuration
public class AppProperties {

    private String staticHost;

    private String staticDiskPath;

    private  String temporaryDiskPath;

    private String  temporaryUriPath;


    private String wxsHost;

    public String getStaticHost() {
        return staticHost;
    }

    public void setStaticHost(String staticHost) {
        this.staticHost = staticHost;
    }

    public String getStaticDiskPath() {
        return staticDiskPath;
    }

    public void setStaticDiskPath(String staticDiskPath) {
        this.staticDiskPath = staticDiskPath;
    }

    public String getTemporaryDiskPath() {
        return temporaryDiskPath;
    }

    public void setTemporaryDiskPath(String temporaryDiskPath) {
        this.temporaryDiskPath = temporaryDiskPath;
    }

    public String getTemporaryUriPath() {
        return temporaryUriPath;
    }

    public void setTemporaryUriPath(String temporaryUriPath) {
        this.temporaryUriPath = temporaryUriPath;
    }

    public String getWxsHost() {
        return wxsHost;
    }

    public void setWxsHost(String wxsHost) {
        this.wxsHost = wxsHost;
    }

    @PostConstruct
    public void init(){
        FileIOUtils.forceMakeDir(new File(getStaticDiskPath()));
        FileIOUtils.forceMakeDir(new File(getTemporaryUriPath()));
    }

}
